#!/bin/bash
#
# Script for Deploy Action
#

source $(dirname $0)/utils.sh

# saving to file on disk
XML_FILE=$1
mkdir -p $(dirname $XML_FILE)
cat > $XML_FILE

# running vm and getting its name
VBOX_NAME=$(vbox_run_vm $XML_FILE)
STATUS=$?

debug "OUTPUT TEXT FROM DEPLOY: $VBOX_NAME (status ${STATUS})"

if [ $STATUS != 0 ]; then
	vbox_destroy_vm "$VBOX_NAME"
	exit 1
fi

echo $VBOX_NAME

exit 0
